package com.tangji.signaltower.runners;

import com.alibaba.fastjson.JSON;
import com.tangji.antenna.bean.EventFactory;
import com.tangji.antenna.bean.ProviderTypeEnum;

import javax.websocket.ClientEndpoint;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@ClientEndpoint
public class ActiveSymbols {

    @OnOpen
    public void onOpen(Session session) throws IOException {
        Map<String,Object> request = new HashMap<>();
        request.put("active_symbols","brief");
        request.put("product_type","basic");

        String ticksStr = JSON.toJSONString(request);
        System.err.println(ticksStr);
        session.getBasicRemote().sendText(ticksStr);
    }

    /**
     * ask price  要价 就是卖价
     * bid price 就是买入价
     * @param message
     */
    @OnMessage
    public void onMessage(String message) {
        System.out.println("当前可用市场: "+message);

//        EventFactory.saveDataToQueue(ProviderTypeEnum.POLYGON, message, null);
    }

}
